package com.example.administrator.myapplication.data;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.List;
import java.util.UUID;

/**
 * Created by Administrator on 2017/11/27.
 */

public class Task implements Parcelable{

    private String id;
    private String name;            //姓名
    private String position;        //位置
    private int pipeOut;            //管线是否老化 1,老化  0，未老化
    private String brand;           //品牌
    private float consumption;      //用气量
    private long date;            //日期
    private List<String> imgPath;   //图片路径

    public Task() {
    }

    public Task(String name, String position, int pipeOut, String brand, float consumption,
                long date, List<String> imgPath) {
        this(UUID.randomUUID().toString(),name,position,pipeOut,brand,consumption,date,imgPath);
    }


    public Task(String id, String name, String position, int pipeOut, String brand,
                float consumption, long date, List<String> imgPath) {
        this.id = id;
        this.name = name;
        this.position = position;
        this.pipeOut = pipeOut;
        this.brand = brand;
        this.consumption = consumption;
        this.date = date;
        this.imgPath = imgPath;
    }

    protected Task(Parcel in) {
        id = in.readString();
        name = in.readString();
        position = in.readString();
        pipeOut = in.readInt();
        brand = in.readString();
        consumption = in.readFloat();
        date = in.readLong();
        imgPath = in.createStringArrayList();
    }

    public static final Creator<Task> CREATOR = new Creator<Task>() {
        @Override
        public Task createFromParcel(Parcel in) {
            return new Task(in);
        }

        @Override
        public Task[] newArray(int size) {
            return new Task[size];
        }
    };

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public int getPipeOut() {
        return pipeOut;
    }

    public void setPipeOut(int pipeOut) {
        this.pipeOut = pipeOut;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public float getConsumption() {
        return consumption;
    }

    public void setConsumption(float consumption) {
        this.consumption = consumption;
    }

    public long getDate() {
        return date;
    }

    public void setDate(long date) {
        this.date = date;
    }

    public List<String> getImgPath() {
        return imgPath;
    }

    public void setImgPath(List<String> imgPath) {
        this.imgPath = imgPath;
    }


    @Override
    public String toString() {
        return "Task{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", position='" + position + '\'' +
                ", pipeOut=" + pipeOut +
                ", brand='" + brand + '\'' +
                ", consumption=" + consumption +
                ", date='" + date + '\'' +
                ", imgPath=" + imgPath +
                '}';
    }

    @Override
    public boolean equals(Object obj) {

        if (obj instanceof Task){
            String objId = ((Task) obj).getId();
            if (objId != null && id.equals(objId)){
                return true;
            }
        }
        return false;
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(id);
        dest.writeString(name);
        dest.writeString(position);
        dest.writeInt(pipeOut);
        dest.writeString(brand);
        dest.writeFloat(consumption);
        dest.writeLong(date);
        dest.writeStringList(imgPath);
    }
}
